<template>
  <div>
    <dt-modal-edit
      ref="edit"
      :title="title"
      :width="900"
      @ok="onOk"
      :labelWidth="130"
      :showOk="info.__type == 'approve'"
      :cancelText="info.__type == 'approve' ? '取消' : '关闭'"></dt-modal-edit>
  </div>
</template>

<script>
  import checkOpt from '../opt/check.js'
  import extendMgr from '@/biz/bonus/bonusExtend.js'

  export default {
    data() {
      return {
        info: {
          operation: '',
          approveContent: ''
        },
        title: ''
      }
    },

    methods: {
      getDetail(extendId) {
        extendMgr.getExtendDetail({ extendId }).then((res) => {
          Object.assign(this.info, res)
          this.$refs.edit.show(new checkOpt(this.info), this.info)
        })
      },
      onOk(data) {
        let params = {
          extendId: data.extendId,
          operation: data.operation,
          approveContent: data.approveContent
        }
        console.log(data, params)
        extendMgr.updateBoExtendStatus(params).then((res) => {
          this.$Message.success('审批成功')
          this.$refs.edit.hide()
          this.$emit('success')
        })
      },
      show(val) {
        this.info.__type = val.type
        this.title = val.title
        this.getDetail(val.extendId)
      }
    }
  }
</script>

<style lang="scss" scoped>
  ::v-deep .ivu-date-picker-header {
    display: none;
  }
</style>
